//我的售后
import { View, Text,Image } from '@tarojs/components'
import { AtIcon,AtTabs, AtTabsPane,AtCard  } from 'taro-ui'
import Taro from '@tarojs/taro'
import './myalter.less'
import HTTP from '../../../service/api'
import { useState,useEffect } from 'react'
import store from '../../../store/index.js'
const Myalter=()=>{
    //tab操作
    const [tabList,settable]=useState([{ title: '全部订单' }, { title: '待处理' }, { title: '已处理' }])
    const [current,setcurrent]=useState(0)
    const handle=(value)=>{
        setcurrent(value)
    }
    //获取初始数据
    const [alldata,setalldata]=useState([{}])
    useEffect(()=>{
        Taro.request({
            url:HTTP.api3+'/portalRefund/myRefund',
            method:'post',
            header:{
                'content-type':'application/x-www-form-urlencoded'
            },
            data:{
                userId:JSON.parse(JSON.stringify(store.userInformation.id)),
                selectType:current
            }
        }).then(res=>{
            console.log(res);
            setalldata(res.data.data);
        })
    },[current])
    // console.log(alldata);
    //售后订单数据
    const orderdata=(item)=>{
        store.setoderData(item)
    }

    return(
        <View>
            <View>
                <AtTabs current={current} tabList={tabList} onClick={handle}>
                <AtTabsPane current={current} index={0} >
                        {alldata.map((item,index)=>{
                            return(
                                <View className='infoBox' onClick={()=>(orderdata(item))}>
                                    <View style={{fontSize:'16px',margin:'5% 0% 0 0%'}}>售后类型：{item.refundType==0?'退货退款':'直接换货'}</View>
                                    <View className='allorder'>
                                        <View className='orderlist'>
                                            <Image src={item.img} style={{width:'50px',height:'50px',background:'red',margin:'0 5px'}}></Image>
                                            <View>
                                                <View>商品名称：{item.properties}</View>
                                                <View>sku数量:{item.costs}</View>
                                                <View>实付{item.costs}元</View>
                                            </View>
                                        </View>
                                        <View className='moneySuccess'>
                                            <View>{item.applyTime}</View>
                                            <View style={{margin:'15px 0'}}>退款成功</View>
                                        </View>
                                    </View>
                            </View>
                            )
                        })}
                        </AtTabsPane>
                    
                    <AtTabsPane current={current} index={1}>
                    {alldata.map((item,index)=>{
                            return(
                                <View className='infoBox'>
                                <View style={{fontSize:'16px',margin:'5% 0% 0 0%'}}>售后类型：{item.refundType==0?'退货退款':'直接换货'}</View>
                                <View className='allorder'>
                                    <View className='orderlist'>
                                        <Image src={item.img} style={{width:'50px',height:'50px',background:'red',margin:'0 5px'}}></Image>
                                        <View>
                                            <View>商品名称：{item.properties}</View>
                                            <View>sku数量:{item.costs}</View>
                                            <View>实付{item.costs}元</View>
                                        </View>
                                    </View>
                                    <View className='moneySuccess'>
                                        <View>{item.applyTime}</View>
                                        <View style={{margin:'15px 0'}}>退款成功</View>
                                    </View>
                                </View>
                            </View>
                            )
                        })}
                    </AtTabsPane>
            <AtTabsPane current={current} index={2}>
            {alldata.map((item,index)=>{
                            return(
                                <View className='infoBox'>
                                <View style={{fontSize:'16px',margin:'5% 0% 0 0%'}}>售后类型：{item.refundType==0?'退货退款':'直接换货'}</View>
                                <View className='allorder'>
                                    <View className='orderlist'>
                                        <Image src={item.img} style={{width:'50px',height:'50px',background:'red',margin:'0 5px'}}></Image>
                                        <View>
                                            <View>商品名称：{item.properties}</View>
                                            <View>sku数量:{item.costs}</View>
                                            <View>实付{item.costs}元</View>
                                        </View>
                                    </View>
                                    <View className='moneySuccess'>
                                        <View>{item.applyTime}</View>
                                        <View style={{margin:'15px 0'}}>退款成功</View>
                                    </View>
                                </View>
                            </View>
                            )
                        })}
            </AtTabsPane>
            </AtTabs>
            </View>
        </View>
    )
}
export default Myalter;